#pragma once

#include <gofcl_usart_stat.h>

typedef struct {
	u32_s parity_err : 1;
	u32_s frame_err : 1;
	u32_s noise_err : 1;
	u32_s overrun_err : 1;
	u32_s idle_frame : 1;
	u32_s has_unread : 1;
	u32_s trans_complete : 1;
	u32_s trans_avl : 1;
	u32_s lin_break : 1;
	u32_s cts_change : 1;
	u32_s : 22;
} usart_stat_expl_s;

_Static_assert(sizeof(usart_stat_expl_s) == 4,
	       "Struct usart_stat_expl_s defined error!");

// 获取给定USART的当前状态
static inline usart_stat_expl_s usart_get_stat(usart_qe usart_q) {
	union {
		usart_stat_expl_s e;
		usart_stat_s s;
	} es = {
		.s = usart_rreg_stat_s(usart_q),
	};
	return es.e;
}
